﻿package {
	import flash.display.MovieClip;
	import flash.display.Loader;
	import flash.net.URLRequest;
	import flash.events.Event;
	
    public class PicLoader{
        public static function loadPic(mainImgMC:MovieClip, url:String){
			if(mainImgMC.picBgMC){
				mainImgMC.removeChild(mainImgMC.picBgMC);
			}
			mainImgMC.picBgMC = new MovieClip();
			var loader:Loader = new Loader();
			var urlReq:URLRequest = new URLRequest();
			loader.addEventListener(Event.COMPLETE, completeHandler);
			urlReq.url = url;
			loader.load(urlReq);
			
			mainImgMC.addChild(loader);
			trace(mainImgMC);
		}
		
		public static function completeHandler(evt:Event):void{
			trace(evt.target.width);
		}
		
    }
}